<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
	<head> 
    <meta charset="UTF-8">
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    <script>
    
   $(document).ready(function(){
	   $("#backBtn").click(function(){
           $("#showHtml").removeClass("showHtml");
           $("#confirmPage").css("display","none");
           $("#editPage").css("display","block");
           $("#showHtml").find("input").removeAttr("disabled");
           $("#showHtml").find("textarea").removeAttr("disabled");
           return false;
       });
	}); 
    
   
   //删除方法
   function checkForm(){
	 //获取 iframe 数量 
   	var frLength = window.parent.frames.length;
   	//父画面下标 
   	var parentIndex = frLength-2;
   	var params = $("#inputForm").serialize();
       $.post("${ctx}/database/message/updateChild",params,function(result) {
            // 提示信息
               window.parent.frames[parentIndex].newSearch();
                // 关闭页面
               closeWin(); 
            
       },'html');
  }
   
   
    //保存方法
    var checkaaaaaForm={
            t:null,
            check:function(t){
                $(t).attr("disabled",true);
                this.t=t;	
                $("#inputForm").validate({
                    // 重名验证
                    rules: {
                     itemValue: {remote: "${ctx}/database/message/formALL?oldItemValue=" +$("#oldItemValue").val() },
                    },
                    messages: {
                     //数据值以存在
                     itemValue: {remote: '<spring:message code="itemValue_exist"/>'},
                    },
                    fail: function(element,e) {  
                         $(saveForm.t).attr("disabled",false);
                    },
                    
                    submitHandler: function(form) {
   	                 $("#showHtml").addClass("showHtml");
   	                 $("#confirmPage").css("display","block");
   	                 $("#editPage").css("display","none");
   	                 $(checkForm.t).attr("disabled",false);
   	                 $("#showHtml").find("input").attr("disabled","disabled");
   	                 $("#showHtml").find("textarea").attr("disabled","disabled");
                    }
                });
                
                // 提交表单
                $("#inputForm").submit(); 
            }
    }
    
/*     var saveForm={
    		s:null,
            t:null,
            save:function(s,t){
                $(t).attr("disabled",true);
                this.s=s;
                this.t=t;
                // 格式化，去除逗号
                
                formUnFormat($("#inputForm"));
                $("#showHtml").find("input").removeAttr("disabled");
                $("#showHtml").find("textarea").removeAttr("disabled");
         	   var params = $("#inputForm").serialize();
                $.post("${ctx}/database/message/save",params, function(result) {
               	 // 提示信息
                    tipParent(result.message);
                    // 返回状态
                    if(result.statusCode==STATUSCODEOK){
                        if(saveForm.s==1){

                         // 刷新页面
                            window.parent.frames[0].searchListForm();
                            
                        }else{
                            window.parent.frames[0].searchListForm();
                            closeWin(); 
                        }
                      }else{
                          $(saveForm.t).attr("disabled",false);
                      }
                },'json');
            } 
       } */
       
    //子项目保存
    var saveForm={
            s:null,
            t:null,
            save:function(s,t){
                $(t).attr("disabled",true);
                this.s=s;
                this.t=t;
              //获取 iframe 数量 
               	var frLength = window.parent.frames.length;
               	//父画面下标 
               	var parentIndex = frLength-2;
                // 从表单中获取数据
                var params = $("#inputForm").serialize();
                $.post("${ctx}/database/message/saveSub", params, function(result) {
                     // 刷新页面
                    window.parent.frames[parentIndex].addItemValue();
                     // 关闭
                    closeWin(); 
                }, 'json');
            } 
    }
    </script> 
    </head>
	<body>
    
	<!-- 创建页面head部 -->
	<div id="editPage" class="layerHeader clearfix">
		<c:choose>
	        <c:when test="${dict.id!=null && dict.id!=''}">
	             <!-- 修改编辑 -->
	            <p class="headerTitle"><spring:message code="dict_modifyDict"/></p>
	        </c:when>
	        <c:otherwise>
	             <!-- 新建 -->
	            <p class="headerTitle"><spring:message code="dict_createDict"/></p>
	        </c:otherwise>
	    </c:choose>
	    <div class="headerButton clearfix">
	    <shiro:hasPermission name="database:message:edit">
	       <button type="button"  onclick="saveForm.save(0,this)"><spring:message code="btn_ok"/></button>
	    </shiro:hasPermission>
	       <button type="button" onclick="closeWin()"><spring:message code="btn_cancle"/></button>
	    </div>
	</div>
	<!-- 确认页面head部 -->
	<div id="confirmPage" class="layerHeader clearfix" style="display:none">
		<p class="headerTitle"><spring:message code="dict_confirmDict"/></p>
	    <div class="headerButton clearfix">
	        <shiro:hasPermission name="database:message:edit">
	        <button type="button" id="saveBtn" onclick="saveForm.save(0,this)"><spring:message code="common_save"/></button>
 			</shiro:hasPermission>
	        <button type="button" id="backBtn""><spring:message code="btn_cancle"/></button>
	    </div>
	</div>
<div id="showHtml">
<form id="inputForm">
    <input type="hidden" id="id" name="id" value="${dict.id}"/>
    <input type="hidden" id="version" name="version" value="${dict.version}"/>
    <input type="hidden"  id="listLength" value="${fn:length(dictList) } "/>
    <input type="hidden" id="oldItemValue" name="oldItemValue" value="${dict.oldItemValue}"/>
    <input type="hidden" id="delIndex" name="delIndex" value="${dict.delIndex}"/>
	<div class="smList">
	        <div class="items clearfix">
	        	<div class="col-50 clearfix haveToBox">
	        		<!-- 数据代码 -->   
	                <p class="tit"><spring:message code="dict_itemCode" /></p>
					<label>${dict.itemCode}</label>
					<input type="hidden" id="itemCode" name="itemCode" value="${dict.itemCode}">
	            </div>            
	            <div class="col-50 right clearfix haveToBox">
	            	<!-- 数据值 -->
	                <p class="tit"><spring:message code="dict_itemValue" /></p>
					<input id="itemValue" name="itemValue" value="${dict.itemValue}" onblur="changeItemValue()" data-rule-notEqualTo="#itemCode" data-msg-notEqualTo="<spring:message code="dictItemValueAndItmeCodeNotRepetition"/>" 
					data-rule-required="true"  data-msg-required="<spring:message code="dict_pleaseInputItemValue"/>"  data-rule-lettersnumbers="true"  data-msg-lettersnumbers="<spring:message code="dict_pleaseInputItemValue"/>">
                    <p class="haveTo">*</p>
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix haveToBox">
	        		<!-- 中文名称 -->
	                <p class="tit"><spring:message code="dict_itemNameCn" /></p>
	                <input id="itemNameCn" name="itemNameCn" value="${dict.itemNameCn}" data-rule-required="true" data-msg-required="<spring:message code="dict_pleaseInputItemCn"/>">
	                <p class="haveTo">*</p>
	            </div>
	            <div class="col-50 right clearfix ">
	            	<!-- 中文略称 -->
	                <p class="tit"><spring:message code="dict_itemShortNameCn" /></p>
	                <input id="itemShortNameCn" name="itemShortNameCn" value="${dict.itemShortNameCn}">
	              
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix haveToBox">
	        		<!-- 英文名称 -->
	                <p class="tit"><spring:message code="dict_itemNameEn" /></p>
	                <input id="itemNameEn" name="itemNameEn" value="${dict.itemNameEn}" data-rule-required="true" data-msg-required="<spring:message code="dict_pleaseInputItemEn"/>">
	            	<p class="haveTo">*</p>
	            </div>
	            <div class="col-50 right clearfix">  
	            	 <!-- 英文略称 -->
	                <p class="tit"><spring:message code="dict_itemShortNameEn" /></p>
	                <input id="itemShortNameEn" name="itemShortNameEn" value="${dict.itemShortNameEn}">
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix haveToBox">
	        		<!-- 日文名称 -->
	                <p class="tit"><spring:message code="dict_itemNameJp" /></p>
	                <input id="itemNameJp" name="itemNameJp" value="${dict.itemNameJp}" data-rule-required="true" data-msg-required="<spring:message code="dict_pleaseInputItemJp"/>">
	            	<p class="haveTo">*</p>
	            </div>
	            <div class="col-50 right clearfix">
	            	<!-- 日文略称 -->
	                <p class="tit"><spring:message code="dict_itemShortNameJp" /></p>
	                <input id="itemShortNameJp" name="itemShortNameJp" value="${dict.itemShortNameJp}">
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix haveToBox">
	        		<!-- 序号 -->
	                <p class="tit"><spring:message code="dict_itemSort" /></p>
	            	<input id="itemSort" name="itemSort" value="${dict.itemSort}" data-rule-nonnegativeInteger="true"  data-msg-nonnegativeInteger="<spring:message code="Please_enter_a_positive_integer"/>" 
	            	data-rule-required="true" data-msg-required="<spring:message code="dict_pleaseInputItemSort"/>">
					<p class="haveTo">*</p>
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix">
	        		<!--状态-->
					<p class="tit"><spring:message code="dict_state" /></p>
					<div class="labelBox">
						<!--启用-->
						<label> <input type="radio" name="enableFlag"
							checked='checked' value="1"
							<c:if test="${dict.enableFlag eq 1}">checked="checked"</c:if>
							class="rast" /> <spring:message code="dict_enable" /> 
						</label>
						<!--停用-->
						<label><input type="radio" name="enableFlag" value="0"
							<c:if test="${dict.enableFlag eq 0}">checked="checked"</c:if>
							class="rast" /> <spring:message code="dict_disable" /> 
						</label>
					</div>
	            </div>
	            
	          
	        </div>
	      
	        <div class="items clearfix">
		       <!-- 描述 -->
               <p class="tit"><spring:message code="dict_remarks"/>(0/100)</span></p>
               <textarea style="width:300px;height: 60px" name="remarks"  value="${dict.remarks}">${dict.remarks}</textarea>
		    </div> 
	</div>
</form>
</div>
</body>
</html>